package org.yenn.pattern.aliyun.behavioral.observer.impl;

import org.yenn.pattern.aliyun.behavioral.observer.Observer;
import org.yenn.pattern.aliyun.behavioral.observer.Subject;

/**
 * 步骤 3
 * 创建实体观察者类。
 */
public class BinaryObserver extends Observer {

    public BinaryObserver(Subject subject){
        this.subject = subject;
        this.subject.attach(this);
    }

    @Override
    public void update() {
        System.out.println( "Binary String: "  + Integer.toBinaryString( subject.getState() ) );
    }}